package com.tinckay.common.constant;

import com.baomidou.mybatisplus.extension.api.IErrorCode;
import org.springframework.http.HttpStatus;

/**
 * 响应码枚举,参考HTTP状态码的语义
 *
 * @author yuanjie
 */
public enum ResultEnum implements IErrorCode {

    /**
     * 创建
     */
    CREATED(201, "CREATED"),

    /**
     * 非权威信息
     */
    ACCEPTED(202, "ACCEPTED"),

    /**
     * 身份未认证
     */
    UNAUTHORIZED(401, "未认证"),

    /**
     * 需要付款
     */
    PAYMENT_REQUIRED(402, "需要付款"),

    /**
     * 被禁止
     */
    FORBIDDEN(403, "被禁止"),

    /**
     * 接口不存在
     */
    NOT_FOUND(404, "接口不存在"),


    /**
     * 服务器内部错误
     */
    INTERNAL_SERVER_ERROR(500, "服务器内部异常"),

    /**
     * 自定义状态码
     * UnknownAccountException 未知账户
     */
    UNKNOWN_ACCOUNT(1000, "未知账户"),

    /**
     * LockedAccountException 账户被锁定
     */
    LOCKED_ACCOUNT(1001, "账户被锁定"),

    /**
     * 用户禁用 DisabledAccountException
     */
    DISABLED_ACCOUNT(1002, "用户被禁止"),

    /**
     * 过期凭证
     */
    EXPIRED_CREDENTIALS(1003, "过期凭证"),

    /**
     * 错误的凭据
     */
    INCORRECT_CREDENTIALS(1004, "错误凭证");

    private final long code;
    private final String msg;

    ResultEnum(long code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    @Override
    public String toString() {
        return String.format(" ErrorCode:{code=%s, msg=%s} ", code, msg);
    }

    @Override
    public long getCode() {
        return code;
    }

    @Override
    public String getMsg() {
        return msg;
    }


}
